package com.braveman.im.factory;


import android.os.Bundle;
import android.util.SparseArray;

import com.braveman.im.ui.fragment.FriendsForMingPianFragment;
import com.braveman.im.ui.fragment.FriendsFragment;
import com.braveman.im.ui.fragment.GroupFragment;
import com.ht.baselibs.ui.base.BaseFragment;

public class FragmentFactoryForIM {

    public static final int FRAGMENT_IM_TAB1 = 11;
    public static final int FRAGMENT_IM_TAB2 = 21;
    public static final int FRAGMENT_IM_TAB3 = 31;
    public static final int FRAGMENT_IM_TAB4 = 41;

    public static final SparseArray<BaseFragment> mHomeIMTabMap = new SparseArray();

    public static BaseFragment getTabFragment(int position) {
        BaseFragment fragment = mHomeIMTabMap.get(position);
        if (fragment == null) {
            switch (position) {
                case FRAGMENT_IM_TAB1:
                    fragment = new GroupFragment();
                    break;
                case FRAGMENT_IM_TAB2:
                    fragment = new FriendsFragment();
                    break;
                case FRAGMENT_IM_TAB3:
//                    fragment = new FriendsFragment();
                    break;
                case FRAGMENT_IM_TAB4:
                    fragment = new FriendsForMingPianFragment();
                    break;

            }
            mHomeIMTabMap.put(position, fragment);
            Bundle bundle = new Bundle();
            bundle.putBoolean(BaseFragment.IS_ATTACH_FRAGMENT_LAYOUT, true);
            fragment.setArguments(bundle);
        }
        return fragment;
    }
}
